#include "progress.h"
#include <string.h>
#include <unistd.h>
#define M 102
#define STYLE '='
#define STYLEEND '>'
char Spin_char[] = "|/-\\";

//实现缓冲进度条
void progress()
{
  char bar[M];
  memset(bar,'\0',sizeof(bar));
  int i = 0;
  while(i <= 100)
  {
    printf("[\033[47;31m%-100s\033[0m][%d%%][%c]\r",bar,i,Spin_char[i%4]);  //左对齐
    fflush(stdout); //手动刷新缓冲区
    bar[i++] = STYLE;
    if(i < 100)
    bar[i] = STYLEEND;
    usleep(100000);
  }
  printf("\n");
}

